<template>
  <div>
       <a-table
          :rowKey="record => record.id"
          :loading="loading"
          :pagination="false"
          :columns="columns"
          :dataSource="tableData">
       </a-table>
       <a-pagination style="text-align:right;margin-top:10px;" @change="onPageChange"  :current="page" :pageSize="size" :total="total" />
  </div>
</template>

<script>
import { transFormService } from '@/services/index'
const columns = [
  {
    dataIndex: 'id',
    key: 'id',
    title: '转单id',
    width: 200
    // fixed: 'left'
  },
  {
    title: '订单号',
    dataIndex: 'orderNum',
    key: 'orderNum'
    // fixed: 'left'
  },
  {
    title: '分单时间',
    dataIndex: 'orderDate',
    key: 'orderDate'
  },
  {
    title: '从SkuCode',
    dataIndex: 'fromProductCode',
    key: 'fromProductCode'
  },
  {
    title: '寄送地',
    key: 'fromBeLocation',
    dataIndex: 'fromBeLocation'
  },
  {
    title: '转SkuCode',
    dataIndex: 'toProductCode',
    key: 'toProductCode'
    // fixed: 'right'
  }
].map(s => {
  // if (!s.width) {
  //   s.width = 250
  // }
  s.align = 'center'
  return s
})

export default {
  data () {
    return {
      id: '',
      page: 1,
      size: 5,
      total: 0,
      tableData: [],
      columns,
      loading: true
    }
  },
  methods: {
    onPageChange (current) {
      this.loadOrderData({
        id: this.id,
        page: current - 1
      })
    },
    loadOrderData ({ id, page }) {
      if (!this.loading) this.loading = true
      transFormService.loadOrderDataByLogId({
        transFormLogId: id,
        page,
        size: this.size
      }).then(
        ({ isSuccess, data }) => {
          this.loading = false
          if (isSuccess) {
            const { content, totalElements } = data
            this.tableData = content
            this.total = totalElements
            this.page = page + 1
            this.id = id
          }
        }
      )
    }
  }
}
</script>

<style scoped>

</style>>
